<?php

/**
 * SearchForm class.
 * SearchForm is the data structure for keeping
 * user search form data. It is used by the 'search' action of 'ReportController'.
 */
class RightForm extends CFormModel
{
	public $role;
	public $rights = array();


	/**
	 * Declares the validation rules.
	 * The rules state that username and password are required,
	 * and password needs to be authenticated.
	 */
	public function rules()
	{
		return array(
			//array('start_date, end_date', 'required'),
			array('role, rights', 'safe'),
		);
	}
	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels()
	{
		return array(
			'role'=>'权限组',
			'rights'=>'操作权限',
		);
	}
	
	public function getRightsByRole()
	{
		$this->rights = Authitemchild::model()->getChilds($this->role);
	}
	
	public function setRights()
	{
		Authitemchild::model()->setChilds($this->role,$this->rights);
	}

}
